﻿using System;
using System.Collections.Generic;
using System.Text;
using Ex04.Menus.Interfaces;

namespace Ex04.Menus.Test
{
    public class InterfacesMenuUser : IMenuItemObserver
    {
        private Interfaces.MainMenu m_MainMenu;

        public InterfacesMenuUser()
        {
            m_MainMenu = new MainMenu("Interfaces Main Menu");

            MenuItem firstItem = new MenuItem("First - Should Open A SubMenu.");
            MenuItem secondItem = new MenuItem("Second - Should Invoke An Action.", this);
            MenuItem thirdItem = new MenuItem("Third - Should Open A SubMenu.");
            MenuItem fourthItem = new MenuItem("Fourth - Should Invoke An Action.", this);

            m_MainMenu.AddMenuItem(firstItem);
            m_MainMenu.AddMenuItem(secondItem);
            m_MainMenu.AddMenuItem(thirdItem);
            m_MainMenu.AddMenuItem(fourthItem);

            MenuItem firstFirstItem = new MenuItem("First First - Should Invoke An Action.", this);
            MenuItem firstSecondItem = new MenuItem("First Second - Should Invoke An Action.", this);
            MenuItem firstThirdItem = new MenuItem("First Third - Should Invoke An Action.", this);

            firstItem.AddMenuItem(firstFirstItem);
            firstItem.AddMenuItem(firstSecondItem);
            firstItem.AddMenuItem(firstThirdItem);

            MenuItem ThirdFirstItem = new MenuItem("Third First - Should Open A SubMenu.");
            MenuItem ThirdSecondItem = new MenuItem("Third Second - Should Invoke An Action.", this);

            thirdItem.AddMenuItem(ThirdFirstItem);
            thirdItem.AddMenuItem(ThirdSecondItem);

            MenuItem ThirdFirstFirstItem = new MenuItem("Third First First - Should Invoke An Action.", this);
            MenuItem ThirdFirstSecondItem = new MenuItem("Third First Second - Should Invoke An Action.", this);

            ThirdFirstItem.AddMenuItem(ThirdFirstFirstItem);
            ThirdFirstItem.AddMenuItem(ThirdFirstSecondItem);
        }

        public void ItemChosen(MenuItem i_MenuItem)
        {
            string messageToUser = string.Format("You chose: {0}", i_MenuItem.DisplayText);
            Console.WriteLine(messageToUser);
            Console.ReadLine();
        }

        public void ShowMenu()
        {
            m_MainMenu.Show();
        }
    }
}